const xlsx = require('node-xlsx');
const fs = require('fs');

class Xlsx {

  constructor(file) {
    this.file = file;
    this.sheets_data = [];
  }

  add(sheet_data) {
    this.sheets_data.push(sheet_data);
  }

  writeFileSync() {
    let buffer = xlsx.build(this.sheets_data);

    fs.writeFileSync(this.file, buffer, {
      'flag': 'w+'
    });
  }
}

exports.Xlsx = Xlsx;